<?php

namespace App\Http\Controllers;

use App\Order;
use App\Repository\WordRepository;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Response;

class WordController extends Controller
{
    public function show(int $id)
    {
        $order = Order::findOrFail($id);
//        $view =   view('word', compact('order'));
//        // return $view;
//        $fp = fopen('./word.docx', 'w');
//        fwrite($fp, $view);
//        fclose($fp);
//        return redirect(asset('word.docx'));

        $word = new WordRepository();

        $name = $word->word($order);
        return redirect($name);
    }
}
